package net;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Properties;

public class TestClient {
	public static void main(String[] args) throws Exception, IOException{
		/*Map<String,String> env= System.getenv();*/
		/*for(String key:env.keySet()){
			System.out.println(key+" "+env.get(key));
		}*/
		Properties envs = System.getProperties();
		for(Object key:envs.keySet()){
			System.out.println(key+"\t\t"+envs.get(key));
		}
		
		String encoding = System.getProperty("sun.jnu.encoding");
		Socket socket = new Socket("127.0.0.1",8888);
		InputStream in = socket.getInputStream();
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		OutputStream out = socket.getOutputStream();
		String tip = reader.readLine();//服务端必须要加“\n”否则就是没读完，阻塞
		System.out.println(tip);
		out.write("utf-8\n".getBytes());
		String info = reader.readLine();
		System.out.println(info);
		out.close();
		reader.close();
		socket.close();                                 
	}
}
